$(function(){
  
});
//共用字典设置
function _publicSetDialog(objData)
{
    var jsonData = objData.json || '',_title = '';
    if($.isEmptyObject(jsonData))
    {
       _title = '诊疗项目 添加';
    }else{
       _title = '诊疗项目 修改';
    }
    objData.txt = objData.txt || '输入名称';
    objData.top = objData.top || 0;
    _Index.tplDlg({
        title: _title,html:$(objData.id).html(),w:objData.w,h:objData.h,top:objData.top,
        success:function(){
          $(objData.id + "_label").html(objData.txt);
          $(objData.id + "_form :input[name='name']").bind('keyup',function(){
                comUtils.setPyAndWbCode(
                  $(this),
                  $(objData.id + "_form :input[name='py_code']"),
                  $(objData.id + "_form :input[name='wb_code']")
                );
          });
          $(objData.id + "_form :input[name='name']").focus();
          if(!$.isEmptyObject(jsonData))
          {
                _Index.setFormJson(objData.id + '_form',jsonData); 
                setTiChengUnitText(objData.id); //设置--提成设置文字 
          }else{
                buildXiangMuBianHao($(objData.id + "_form :input[name='bianma']")); //生成一个编码
                setTiChengUnitText(objData.id); //设置--提成设置文字
                if(_dictType != 'ALL')
                {
                    $(objData.id + "_form").children().find("select[name='cate_id']").val(_dictType);
                }
          }
          layform.render();
          layform.on('select(xm_tc_mode)', function(_tv){
            if(_tv.value == '1')
            {
                $('#zhenliao_form_tc_unit').html('%');
            }else{
                $('#zhenliao_form_tc_unit').html('');
            }
          });
        }
    },function(lo){
      var param = _Index.getFormJson(objData.id + '_form');
      param.dicttype = _dictType;
      _Index.ajax($(objData.id+"_form").attr('action'),param,function(d){
        if(d.err == 0)
        {
            $(objData.id+"_form :input[name='name']").val('');
            layer.close(lo);
            layer.msg(d.msg, {time: 1000},function(){
                _p = 1;
                _loadList();
            });
        }else{
            layer.msg(d.msg, {time: 2000,anim: 4});
        }
      },'');
    });
}
//添加事件
function _addAction(jsonData)
{
    jsonData = jsonData || '';
    var _w = 1000, _h = 450, _top = 100;
    _publicSetDialog({txt:'<i class="c-red">*</i>项目名称',id:'#tpl_zhenliao',w:_w,h:_h,top:_top,json:jsonData});
}
//不同类型字典表格数据
function getTableConfigField()
{
      return [[
        {field:'bianma', width:180, title: '项目编码'}
        ,{field:'name', minwidth:250, title: '项目名称'}
        ,{field:'price', width:120, align:'center', title: '售价',sort: true}
        ,{field:'ls_unit_txt', width:120, align:'center', title: '售价单位'}
        ,{field:'remarks', width:180, title: '备注'}
        ,{field:'status', width:120, title: '状态',align:'center',templet: "#statusTpl", sort: true}
        ,{field:'create_time', width:180, title: '添加时间',sort: true}
        ,{fixed: 'right', width: 150, align:'center', title: '操作', toolbar: '#table-content-com'}
      ]];
}
//设置--提成设置文字 setTiChengUnitText(objData.id)
function setTiChengUnitText(_obj)
{
    var t1 = $(_obj + "_form").children().find("select[name='xm_tc_mode']").find("option:selected").val();
    if(t1 == '1')
    {
        $('#zhenliao_form_tc_unit').html('%');
    }else{
        $('#zhenliao_form_tc_unit').html('');
    } 
}


